package com.hubing.cloud.app.web.es;

import java.io.Serializable;
import java.util.List;

public class PaginationBean<T> implements Serializable {

	private static final long serialVersionUID = 1440736865488640576L;

	private int currentPage = 1; // 当前页数

	private int totalPages = 0; // 总页数

	private int pageSize = 11; // 每页显示数

	private long totalRows = 0; // 总数据数

	private boolean hasNextPage = true; // 是否有下一页

	private boolean hasPreviousPage = true; // 是否有前一页

	private List<T> header; // 列表的header
	private List<T> result; // 内容

	public int getCurrentPage() {
		if (currentPage < 1) {
			currentPage = 1;
		}
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public long getTotalRows() {
		return totalRows;
	}

	public void setTotalRows(long totalRows) {
		this.totalRows = totalRows;
		//        if (totalRows % pageSize == 0) {
		//            setTotalPages(totalRows / pageSize);
		//        } else {
		//            setTotalPages(totalRows / pageSize + 1);
		//        }
		//        if (currentPage > getTotalPages()) {
		//            currentPage = getTotalPages();
		//        }
		//        if (getCurrentPage() >= getTotalPages()) {
		//            hasNextPage = false;
		//        }
		//        if (currentPage == 1) {
		//            hasPreviousPage = false;
		//        }
	}

	public boolean isHasNextPage() {
		return hasNextPage;
	}

	public void setHasNextPage(boolean hasNextPage) {
		this.hasNextPage = hasNextPage;
	}

	public boolean isHasPreviousPage() {
		return hasPreviousPage;
	}

	public void setHasPreviousPage(boolean hasPreviousPage) {
		this.hasPreviousPage = hasPreviousPage;
	}

	public List<T> getResult() {
		return result;
	}

	public void setResult(List<T> result) {
		this.result = result;
	}

	public List<T> getHeader() {
		return header;
	}

	public void setHeader(List<T> header) {
		this.header = header;
	}

}
